home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC12Menus / Menus.Inits.asm < prev    next >
Encoding:
Assembly Source File  |  1990-06-18  |  11.9 KB  |  343 lines  |  [TEXT/pdos]

  1. *******************************************************************************
  2. *
  3. InitTools           start
  4. *
  5. * Description:      Load and initialize the tools needed. Errors are detected
  6. *                   and FatalError is called if any occur. If there aren't any
  7. *                   errors, the list of menu templates is read and the menu-
  8. *                   bar is created.
  9. *
  10. *
  11. * Inputs:           NONE
  12. *
  13. * Outputs:          NONE
  14. *
  15. * External Refs:
  16. *                   Import FatalError
  17. *
  18. * Entry Points:     NONE
  19. *
  20. *******************************************************************************
  21.                     using Globals
  22.  
  23. ;
  24. ;   Tool Direct page offsets here
  25. ;
  26. QDDPage             equ $0000
  27. EMDPage             equ QDDPage+$0300
  28. CtlDPage            equ EMDPage+$0100
  29. MenuDPage           equ CtlDPage+$0100
  30. LEDPage             equ MenuDPage+$0100
  31. ToolDPSize          equ LEDPage+$0100
  32.  
  33.                     phk                 ; Save program bank register and
  34.                     plb                 ; load it as the data bank register
  35.  
  36.                     tdc
  37.                     sta MyDP            ; Save direct register
  38.  
  39.                     _TLStartup          ; Start Tool Locator
  40.  
  41.                     pha                 ; Space for result
  42.                     _MMStartup          ; Start memory manager
  43.                     PullWord MyID       ; Save it for later use
  44.  
  45.                     _MTStartup          ; Start up Misc Tools
  46.  
  47.                     _IMStartup          ; Start integer math toolset
  48.  
  49.                     PushLong #ToolTable ; Pointer to Tool table
  50.                     _LoadTools          ; Load all RAM based tools
  51.                     bcc IT0005          ; Carry clear means no error
  52.                     brl FatalError      ; Tools can't be loaded. Fatal error!
  53.  
  54. IT0005              ANOP
  55.  
  56. ; Get memory for Tool Direct pages
  57.  
  58.                     pha                 ; Room for result
  59.                     pha
  60.                     PushLong #ToolDPSize ; Number of bytes needed
  61.                     PushWord MyID       ; ID of this application
  62.                     PushWord #attrLocked+attrFixed+attrPage+attrBank
  63.                     PushLong #0         ; Allocate them in bank 0
  64.                     _NewHandle
  65.                     bcc IT0010          ; Test carry for error
  66.                     brl FatalError      ; If no memory we got a fatal error!
  67.  
  68. IT0010              PullLong DPHandle   ; Retrieve handle to our DPage area
  69.  
  70.                     lda [DPHandle]      ; Dereference the handle to get a ptr
  71.                     sta DPPointer       ; to our direct page area and save it.
  72.  
  73.                     PushWord DPPointer  ; QuickDraw uses 3 pages of Dpage
  74.                     PushWord #ScreenMode ; Used to set all master SCB's
  75.                     PushWord #0         ; Zero means use default buf size
  76.                     PushWord MyID       ; Application ID for allocating data
  77.                     _QDStartup          ; Start QuickDraw, turn on SHR Screen
  78.                     bcc IT0015
  79.                     brl FatalError      ; If it can't be started then bomb
  80.  
  81. IT0015              ANOP
  82.                     lda DPPointer       ; Create address for Event Mgr DPage by
  83.                     clc                 ; loading in the pointer to the start
  84.                     adc #EMDPage        ; of DPage and adding Evt Mgr offset.
  85.                     pha                 ; Now push it on the stack.
  86.                     PushWord #20        ; Size of event queue.
  87.                     PushWord #0         ; MouseClamp values.
  88.                     PushWord #ScreenWidth ; These will clamp mouse to screen
  89.                     PushWord #0         ; area only.
  90.                     PushWord #200
  91.                     PushWord MyID
  92.                     _EMStartup          ; Start the event manager
  93.                     bcc IT0020
  94.                     brl FatalError      ; Event manager is also a must
  95. IT0020              ANOP
  96.                     PushWord MyID
  97.                     _WindStartup
  98.                     bcc IT0025
  99.                     brl FatalError
  100. IT0025              ANOP
  101.                     PushWord MyID
  102.                     lda DPPointer
  103.                     clc
  104.                     adc #CtlDPage
  105.                     pha
  106.                     _CtlStartup
  107.                     bcc IT0030
  108.                     brl FatalError
  109. IT0030              ANOP
  110.  
  111.                     PushWord MyID
  112.                     lda DPPointer
  113.                     clc
  114.                     adc #MenuDPage
  115.                     pha
  116.                     _MenuStartUp
  117.                     bcc IT0035
  118.                     brl FatalError
  119. IT0035              ANOP
  120.                     PushWord MyID
  121.                     lda DPPointer
  122.                     clc
  123.                     adc #LEDPage
  124.                     pha
  125.                     _LEStartUp
  126.                     bcc IT0040
  127.                     brl FatalError
  128. IT0040              ANOP
  129.                     PushWord MyID
  130.                     _DialogStartup
  131.                     bcc IT0045
  132.                     brl FatalError
  133. IT0045              ANOP
  134.                     _ListStartup
  135.  
  136.                     _QDAuxStartup       ; no error possible for this call
  137.                     
  138.                     _ScrapStartup       ; No error possible for this call
  139.  
  140.                     _DeskStartup        ; No error possible for this call
  141.  
  142. ; insert application specific tools here
  143.  
  144.                     PushLong #0
  145.                     _RefreshDeskTop
  146.  
  147.                     RTS
  148.  
  149. ToolTable           dc i2'8'            ; Data Block for LoadTools call
  150.                     dc i2'14,$0100'     ; Window Manager
  151.                     dc i2'15,$0100'     ; Menu Manager
  152.                     dc i2'16,$0100'     ; Control Manager
  153.                     dc i2'18,$0100'     ; QDAux
  154.                     dc i2'20,$0100'     ; LineEdit tool set
  155.                     dc i2'21,$0100'     ; Dialog Manager
  156.                     dc i2'22,$0100'     ; Scrap manager
  157.                     dc i2'28,$0100'     ; List Manager
  158.  
  159.                     end
  160.  
  161.                     EJECT
  162. *******************************************************************************
  163. *
  164. FatalError          start
  165. *
  166. * Description:      Routine that is called whenever a tool sends back an error
  167. *                   that can not be recovered from. This routine prints the
  168. *                   error on the screen, waits for a keypress then quits back
  169. *                   to whoever started this application up!
  170. *
  171. *
  172. * Inputs:           A = Error number
  173. *
  174. * Outputs:          NONE (program exits)
  175. *
  176. * External Refs:
  177. *                   Import CloseTools
  178. *
  179. * Entry Points:     NONE
  180. *
  181. *******************************************************************************
  182.                     using Globals
  183.  
  184.                     pha                 ; Push the error code
  185.                     PushLong #ErrNumStr ; Address of storage area
  186.                     PushWord #4         ; Length of string
  187.                     _Int2Hex
  188.  
  189.                     _GrafOff            ; If QD Started, shut off graphics
  190.  
  191.                     PushLong #ErrStr    ; Write error message to the screen
  192.                     _WriteCString
  193.  
  194.                     pha                 ; Space for result
  195.                     PushWord #0         ; No echo
  196.                     _ReadChar           ; Wait for a key to be pressed
  197.                     pla                 ; Discard the key
  198.  
  199.                     jsr CloseTools      ; Shut down all the tools in case
  200. ;                                         any got started up
  201.  
  202.                     _Quit QuitParms     ; Quit back to where we came from.
  203.  
  204.                     brk $FF             ; If the quit fails then just break
  205.                     
  206. ErrStr              dc c'A fatal error has occured $'
  207. ErrNumStr           dc c'xxxx   press any key to exit',i1'0'
  208.  
  209.                     end
  210.  
  211.                     EJECT
  212. *******************************************************************************
  213. *
  214. CloseTools          start
  215. *
  216. * Description:      Shut down the tools I started.
  217. *
  218. *
  219. * Inputs:           NONE
  220. *
  221. * Outputs:          NONE
  222. *
  223. * External Refs:    NONE
  224. *
  225. * Entry Points:     NONE
  226. *
  227. *******************************************************************************
  228.                     using Globals
  229.  
  230.                     _ListShutdown
  231.                     _QDAuxShutDown
  232.                     _DeskShutDown
  233.                     _ScrapShutDown
  234.                     _DialogShutDown
  235.                     _LEShutDown
  236.                     _MenuShutDown
  237.                     _CtlShutDown
  238.                     _WindShutDown
  239.                     _EMShutDown
  240.                     _QDShutDown
  241.                     _MTShutDown
  242.  
  243.                     PushLong DPHandle   ; Dispose of all that DP memory
  244.                     _DisposeHandle
  245.  
  246.                     PushWord MyID
  247.                     _MMShutDown
  248.                     _TLShutDown
  249.  
  250.                     rts
  251.                     end
  252.  
  253.                     EJECT
  254. *******************************************************************************
  255. *
  256. DoAbout             start
  257. *
  258. * Description:      Bring up an Alert Dialog box with our name in it.
  259. *
  260. * Inputs:           NONE
  261. *
  262. * Outputs:          NONE
  263. *
  264. * External Refs:    NONE
  265. *
  266. * Entry Points:     NONE
  267. *
  268. *******************************************************************************
  269.                     using Globals
  270.  
  271.                     pha                 ; space for result
  272.                     PushLong #AboutBox  ; pointer to alert template
  273.                     PushLong #0         ; pointer to a filter proc (0=none)
  274.                     _NoteAlert
  275.                     pla                 ; get the item hit and dispose
  276.  
  277.                     rts
  278.  
  279. ; About Box alert template
  280. ; About Box alert template
  281.  
  282. AboutBox            ANOP
  283. atBoundsRect        dc i2'30,30,100,290'                    ; for 320 use
  284. atAlertID           dc i2'1'            ; this is alert # 1
  285. atStage1            dc i1'$80'          ; draw for this stage
  286. atStage2            dc i1'$81'          ; draw for this stage
  287. atStage3            dc i1'$82'          ; draw for this stage
  288. atStage4            dc i1'$83'          ; draw for this stage
  289. atItem1             dc i4'OKButton'     ; ok button for the alert
  290. atItem2             dc i4'AboutTitle'   ; title of the program
  291. atItem3             dc i4'AboutAut'     ; author
  292. atItem4             dc i4'AboutCR'      ; version number string
  293. atItem5             dc i4'AboutVers'    ; nill to end the list
  294. atEndList           dc i4'0'
  295.  
  296. OKBTitle            dc i1'2',c'OK'
  297. OKButton            ANOP
  298.                     dc i2'1'
  299.                     dc i2'50,200,65,250'
  300.                     dc i2'$000A'        ; standard button
  301.                     dc i4'OKBTitle'
  302.                     dc i2'0'
  303.                     dc i2'0'            ; item flag
  304.                     dc i4'0'            ; no color table
  305.  
  306. AboutTitle          ANOP
  307.                     dc i2'2'
  308.                     dc i2'10,50,20,250'
  309.                     dc i2'$800F'        ; Stat Text
  310.                     dc i4'TitleString'
  311.                     dc i2'0'
  312.                     dc i2'0'            ; item flag
  313.                     dc i4'0'            ; no color table
  314.  
  315. AboutAut            ANOP
  316.                     dc i2'3'
  317.                     dc i2'22,50,32,250'
  318.                     dc i2'$800F'        ; Stat Text
  319.                     dc i4'AutString'
  320.                     dc i2'0'
  321.                     dc i2'0'            ; item flag
  322.                     dc i4'0'            ; no color table
  323.  
  324. AboutCR             ANOP
  325.                     dc i2'4'
  326.                     dc i2'34,50,46,250'
  327.                     dc i2'$800F'        ; Stat Text
  328.                     dc i4'CRString'
  329.                     dc i2'0'
  330.                     dc i2'0'            ; item flag
  331.                     dc i4'0'            ; no color table
  332.  
  333. AboutVers           ANOP
  334.                     dc i2'5'
  335.                     dc i2'48,50,60,250'
  336.                     dc i2'$800F'        ; Stat Text
  337.                     dc i4'VersString'
  338.                     dc i2'0'
  339.                     dc i2'0'            ; item flag
  340.                     dc i4'0'            ; no color table
  341.  
  342.                     end
  343.